// Copyright (c) 2010, Anthony Cassidy
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modification, are 
// permitted provided that the following conditions are met:
// 
//     * Redistributions of source code must retain the above copyright notice, this list 
//         of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice, this 
//         list of conditions and the following disclaimer in the documentation and/or 
//         other materials provided with the distribution.
//     * Neither the name of the AntsAdventureGameCreator nor the names of its contributors 
//         may be used to endorse or promote products derived from this software without 
//         specific prior written permission.
// 
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
// THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include "KeywordRegistry.h"
#include "RoomRegistry.h"
#include "IEventHandlers.h"
#include "AntsApi.h"
#include "IExtraEventHandlersForUseWithCodes.h"
#include "CLIENTONLYINCLUDE.h"

/*!
ROOMDECLARATION_WITH_CODES_AND_RESOURCE_ROOMS_BEGIN(<i>roomname</i> 
declares a room, similar to ROOMDECLARATION_WITH_CODES, 
but it has the added feature of allowing you to supply Resource Rooms
Resource Rooms are additional rooms whose resources are pulled
in to the inventory and object lists, and whose handlers
get called just after those of the main room.
<br>
Resource Rooms are useful for storing inventory resources 
that can be shared across many rooms.
And they are a good place to store handlers for commands
that should trigger the same thing no matter what room
they are in. For example: use inv1 with inv2.
<br>
Resource Rooms are defined just like normal rooms, using the 
ROOMDECLARATION_WITH_CODES and ROOMDECLARATION_FOR_CPP macros.
Typically the ROOMDECLARATIONis in a header, so you can share it,
and the ROOMDECLARATION_FOR_CPP is in a cpp
You normally wouldn't switch to a room defined 
for the purpose of storing extas.

*/

#define ROOMDECLARATION_WITH_CODES_AND_RESOURCE_ROOMS_BEGIN(roomkeyword) \
class roomkeyword: public IEventHandlers, public IExtraEventHandlersForUseWithCodes\
{\
public:\
    QVector<QString> m_resourceRooms;\
    QString Folder(){ return #roomkeyword;}\
    static void SwitchTo(){ AntsApi::MakeRoomActive(#roomkeyword);}\
    int NumberOfResourceRooms(){ return m_resourceRooms.size();}\
    QString ResourceRoomAt(int i){ return m_resourceRooms[i];}\
    void OnCommandLineExecuteWithCodes(int number, int x=0, int y=0);\
    void OnCommandLineExecute(int iVerb, QString a, QString b, int x=0, int y=0)\
    {\
    int iA = AntsApi::GetKeywordRegistry().GetCodeFor(#roomkeyword, a.toAscii());\
    int iB = AntsApi::GetKeywordRegistry().GetCodeFor(#roomkeyword, b.toAscii());\
    for(int i=0;i<m_resourceRooms.size();i++)\
        {\
        if(iA==-1)\
        iA = AntsApi::GetKeywordRegistry().GetCodeFor(m_resourceRooms[i].toAscii(), a.toAscii());\
        if(iB==-1)\
        iB = AntsApi::GetKeywordRegistry().GetCodeFor(m_resourceRooms[i].toAscii(), b.toAscii());\
                }\
                int k = iB>0? iVerb + iA*iB : iVerb + iA;\
                OnCommandLineExecuteWithCodes(k,x,y);\
    }\
    roomkeyword()\
    {



/*! 
@file ROOMDECLARATION_WITH_CODES_AND_RESOURCE_ROOMS_BEGIN.h
*/

